// This file is part of Indico.
// Copyright (C) 2002 - 2025 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.

@use 'base' as *;
@use 'design_system';
@use 'partials/buttons' as *;
@use 'partials/icons' as *;

/* Styles for the main menu */

#global-menu {
  @extend %text-size-reset;

  // Override menu variables for global menu to use inverse (dark) styling
  --menu-background-color: var(--surface-inverse-color);
  --menu-text-color: var(--text-inverse-color);
  --menu-text-hover-color: var(--text-inverse-color);
  --menu-background-hover-color: var(--surface-highlight-inverse-color);
  --menu-border: none;
  --menu-shadow: none;

  padding: 0 1.4em;
  background: var(--surface-inverse-color);
  border: none;
  margin-bottom: 0;

  li {
    list-style: none; // FIXME: This should be in the global reset
  }

  > menu {
    @extend %menu;
    @extend %flex-row;
  }

  ind-menu > button::after {
    @extend %icon;
    @extend %icon-arrow-down;
    display: block; // XXX: Required for transform to work
  }

  ind-menu > button[aria-expanded='true']::after {
    transform: rotateX(-180deg);
  }

  ind-menu > menu :is(li, a) {
    width: 100%;
  }

  > menu li {
    list-style: none;
    padding: 0;
  }

  li :is(a, button) {
    @extend %flex-row;
    flex: none;

    background: var(--surface-inverse-color);
    color: var(--text-inverse-color);
    padding: 0.7em 1em;
    border: none;

    &:first-child,
    &.arrow:last-of-type {
      border-radius: 0;
    }

    &:hover,
    &.open {
      background: var(--surface-highlight-inverse-color);
    }

    &.arrow {
      @include icon-after('icon-arrow-down');

      &::after {
        vertical-align: middle;
      }
    }
  }

  ind-with-tooltip {
    --flex-layout: flex;
  }
}

/* Header */

div.page-header {
  position: relative;
  background-color: $dark-blue;
  width: 100%;

  img.header-logo {
    margin: 17px 0 10px 40px;
    border: none;
    height: 60px;
  }
}

div.page-header-dark {
  background: #424242;
}

/* Announcements */
div.announcement-bar:not([hidden]) {
  @include font-family-title();

  display: flex;
  align-items: center;
  padding: 0.75em;
  font-size: 1.1em;
  text-align: center;

  .icon {
    margin-right: 0.25em;
    font-size: 1.1em;
  }

  .close-button {
    @extend %button-icon-only;

    display: flex;
    font-size: 1.5em;
    cursor: pointer;

    &::before {
      @extend %icon;
      @extend %icon-close;
    }
  }

  .close-button span {
    @extend %visually-hidden;
  }

  &.highlight {
    background-color: $light-blue;
    color: $dark-black;

    .icon {
      color: $blue;
    }

    .close-button {
      color: $dark-blue;
    }
  }

  &.warning {
    background-color: lighten($light-yellow, 5%);
    color: $dark-black;

    .icon {
      color: $yellow;
    }

    .close-button {
      color: $dark-yellow;
    }
  }

  &.error {
    background-color: $dark-red;
    color: $light-red;

    .icon {
      color: $light-red;
    }

    .close-button {
      color: $light-red;
    }
  }

  &.weak-hidden {
    display: none;
  }
}

/* Breadcrumbs */

nav.main-breadcrumb {
  @include font-family-title();

  background-color: darken($light-gray, 5%);
  border-bottom: 1px solid $gray;
  padding: 0.6em 0 0.6em 40px;

  &.management {
    background-color: #fff;
  }

  .path {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;

    li {
      display: flex;
      align-items: center;
    }

    .sep {
      color: var(--text-secondary-color);
      padding: 0 0.5em;
    }

    .item {
      color: var(--text-color);
      font-size: 12px;
    }

    a.item:hover {
      color: var(--clickable-text-highlight-color);
    }

    .current-page-indicator {
      @extend %visually-hidden;
    }
  }
}

/* Styles for the session bar at the top right corner */

div.session-bar {
  @include font-family-title();

  margin: 0.5em 0.5em 0 0;

  .toolbar {
    padding: 0;
    margin: 0;
  }

  .icon-shield {
    vertical-align: middle;
  }

  .i-button {
    font-weight: normal;

    &.protection-public {
      @extend .accept;
    }

    &.protection-restricted {
      @extend .danger;
    }

    &.protection-network {
      @extend .warning;
    }
  }

  &.sticky-scrolling {
    background-color: transparent;
    box-shadow: none;
    right: 0;
    margin-top: 0;
    padding: 0 0 5px 5px;
    z-index: 999;
  }
}

div.tz-selector-widget {
  .tz-mode-container > div {
    margin-bottom: 0.5em;
  }

  .tz-update-user-container {
    margin: 1em 0;
  }

  .tz-save-container {
    text-align: center;
    margin-top: 1em;
  }
}

/* Impersonation header */

div.impersonation-header {
  padding: 0.5em;
  background-color: $dark-black;
  color: lighten($yellow, 15%);
  font-family: Verdana, sans-serif;
  font-size: 1.1em;

  .text {
    display: inline-block;

    .logged-user-name {
      font-weight: bold;
      color: lighten($yellow, 30%);
      margin: 0.1em;
      line-height: 1em;
      max-width: 200px;
    }

    &::before {
      margin-right: 0.4em;
      font-size: 1.5em;
      line-height: 1em;
      vertical-align: middle;
    }
  }

  .undo-login-as {
    color: inherit;
    float: right;
    margin-right: 2px;
    vertical-align: middle;
    font-size: 1.5em;
    line-height: 1em;
  }
}

.location-info-tip {
  .location-address {
    color: $gray;
    white-space: pre;
  }

  .map-link {
    float: right;
    margin-top: 0.5em;
  }

  h3,
  h4 {
    line-height: 1.2em;
    margin-top: 0 !important;
    margin-bottom: 0;

    &:not(:last-child) {
      margin-bottom: 0.4em;
    }
  }
}
